package com.sky.controller.user;

import com.sky.dto.UserLoginDTO;
import com.sky.pojo.User;
import com.sky.result.Result;
import com.sky.service.user.UserService;
import com.sky.vo.UserLoginVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result<UserLoginVO> login(@RequestBody UserLoginDTO dto){

        return userService.login(dto);
    }
    //测试方法
    @GetMapping("/selectById")
    //将参数设置为key,
    @Cacheable(value="user",key="#userId")
    public User selectById(Long userId){
        return userService.selectById(userId);
    }
}